<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>潜在客户记录</title>
    <meta name="decorator" content="default"/>
    <script src="${ctxStatic}/layer/layer.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#btnAdd").click(function(){
                var memberId=$("#memberId").val();
                var record=$("#record").val();
                if(!record){
                    layer.alert("请输入服务记录",-1);
                    return;
                }
                $.ajax({
                    type : "POST",  //提交方式
                    url : "${ctx}/sys/servicerecord/serviceRecord/ajaxSave",//路径
                    data : {"member.id":memberId,"record":record},//数据，这里使用的是Json格式进行传输
                    success : function(data) {//返回数据根据结果进行相应的处理
                        if(data){
                            layer.alert("操作成功,",function(){
                                window.location.reload();
                            });
                        }else{
                            layer.alert("操作失败",-1);
                        }
                    }
                });
            });
            $(".btn-add").click(function(){
                var id=$(this).data("id");
                if(!id){
                    layer.alert("删除失败，请联系管理员",-1);
                    return;
                }
                layer.confirm('确认要删除吗？', {
                    btn: ['确认','取消'], //按钮
                    shade: false //不显示遮罩
                }, function(index){
                    $.ajax({
                        type : "POST",  //提交方式
                        url : "${ctx}/sys/servicerecord/serviceRecord/ajaxDelete",//路径
                        data : {"id":id},//数据，这里使用的是Json格式进行传输
                        success : function(data) {//返回数据根据结果进行相应的处理
                            if(data){
                                layer.alert("操作成功,",function(){
                                    window.location.reload();
                                });
                            }else{
                                layer.alert("操作失败",-1);
                            }
                        }
                    });
                });


            });


        });
    </script>
</head>
<body>
<input type="hidden" id="memberId" value="${member.id}">
<div class="row" style="text-align: center;"><h2>【${member.nickname}】的记录</h2></div>
<div class="row" style="text-align: center;padding-top: 11px;">
    <div class="col-md-2 col-md-offset-5" style="text-align: center;font-size:32px;overflow: hidden; ">
        客户姓名：<input id="name" type="String" style="width: 60%;height: 30px;"  class="input-xlarge required" />
        客户电话：<input id="tel" type="String" style="width: 60%;height: 30px;"  class="input-xlarge required" />
        客户资料记录：<input id="content" type="text" style="width: 60%;height: 30px;"  class="input-xlarge required" />
        客户回复状态：<input id="member_state" type="text" style="width: 60%;height: 30px;"  class="input-xlarge required" />
        提醒时间：<input id="record_time" type="text" style="width: 60%;height: 30px;"  class="input-xlarge required" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH-mm-ss',isShowClear:false});"/>
        <shiro:hasPermission name="sys:member:member:sr:edit">
            <input id="btnAdd" class="btn btn-danger" type="button" value="添加" />
        </shiro:hasPermission>
    </div>
</div>
<div class="row" style="padding-left: 20px">
    <table id="contentTable" class="table table-striped table-bordered table-condensed">
        <thead>
        <tr>
            <th style="width: 1%">序号</th>
            <th style="width: 10%">记录时间</th>
            <th style="width: 10%">创建人</th>
            <th style="width: 10%">客户姓名</th>
            <th style="width: 10%">电话</th>
            <th style="width: 70%">客户资料记录</th>
            <th style="width: 70%">客户回复状态</th>
            <th style="width: 10%">提醒时间</th>
            <shiro:hasPermission name="sys:member:member:sr:edit">
                <th style="width: 2%">操作</th>
            </shiro:hasPermission>
        </tr>
        </thead>
        <tbody>
        <c:choose>
            <c:when test="${empty srList && fn:length(srList)==0 }">	<tr> <td colspan="5"><div class="col-md-2 col-md-offset-5" style="text-align: center;font-size:32px; line-height:550px; height: 550px;">暂无对该用户的服务记录 </div></td> </tr></c:when>
            <c:otherwise>
                <c:forEach items="${srList}" var="sr" varStatus="p">
                    <tr>
                        <td>${p.index+1}</td>
                        <td>
                            <fmt:formatDate value="${sr.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
                        </td>
                        <td>${sr.createBy.name}</td>
                        <td></td>
                        <td></td>
                        <td>
                                ${sr.record}
                        </td>
                        <td>
                                ${sr.record}
                        </td>
                        <td>
                                ${sr.record}
                        </td>
                        <shiro:hasPermission name="sys:member:member:sr:edit">

                            <td>
                                <a href="#" class="btn-add" data-id="${sr.id }">删除</a>
                            </td>
                        </shiro:hasPermission>
                    </tr>
                </c:forEach>
            </c:otherwise>
        </c:choose>
        <c:forEach items="${page.list}" var="loan">

        </c:forEach>
        </tbody>
    </table>
</div>
</body>
</html>